package cn.com.cifi.mars.web.action.report;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import cn.com.cifi.mars.common.base.BaseAction;
import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.service.ReportService;
import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @Description：报表数据初始化实现
 * @author：yyd
 * @date：2020年2月18日 下午8:14:15
 */
@Slf4j
@RestController
public class ReportController extends BaseAction implements IReportController {
	@Autowired
	private ReportService reportService;

	@Override
	public R initDmDmContractDay(String apiVersion) {
		log.info("###############签约数据初始化（天）   Start: "+ LocalDateTime.now());
		long start = System.currentTimeMillis();
		reportService.initDmDmContractDay();
		long end = System.currentTimeMillis();
		long diff = end-start;
		log.info("###############签约数据初始化（天）   End: "+ LocalDateTime.now());
		return ok("运行时长（毫秒）："+diff);
	}

	@Override
	public R initDmDmContractMonth(String apiVersion) {
		log.info("###############签约数据初始化（月度）   Start: "+ LocalDateTime.now());
		long start = System.currentTimeMillis();
		reportService.initDmDmContractMonth();
		long end = System.currentTimeMillis();
		long diff = end-start;
		log.info("###############签约数据初始化（月度）   End: "+ LocalDateTime.now());
		return ok("运行时长（毫秒）："+diff);
	}

	@Override
	public R initDmDmPlanSupplyMonth(String apiVersion) {
		log.info("###############月度供货数据初始化   Start: "+ LocalDateTime.now());
		long start = System.currentTimeMillis();
		reportService.initDmDmPlanSupplyMonth();
		long end = System.currentTimeMillis();
		long diff = end-start;
		log.info("###############月度供货数据初始化   End: "+ LocalDateTime.now());
		return ok("运行时长（毫秒）："+diff);
	}
}
